package com.nextStep.service;

import com.nextStep.dao.DbConfigMapper;
import com.nextStep.entity.DbConfig;
import com.nextStep.entity.SqlDescComm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("dbConfigService")
public class DbConfigServiceImpl implements DbConfigService {

    @Autowired
    @Qualifier("dbConfigDao")
    private DbConfigMapper dbConfigMapper;

    @Override
    public Integer addConfig(DbConfig dbConfig) {
        Integer status = dbConfigMapper.addConfig(dbConfig);
        return status;
    }

    @Override
    public Integer delConfig(String dbid) {
        Integer status = dbConfigMapper.delConfig(dbid);
        return status;
    }

    @Override
    public List<DbConfig> findConfig(String userid) {
        List<DbConfig> list = dbConfigMapper.findConfig(userid);
        return list;
    }

    @Override
    public  List<SqlDescComm> queryTbColumnName(String tbName) {
        List<SqlDescComm> tbColumn = dbConfigMapper.queryDescTb(tbName);
        return tbColumn;
    }

    @Override
    public DbConfig findConfigOnDbid(String dbid) {
        DbConfig dbConfig = dbConfigMapper.findConfigOnDbid(dbid);
        return dbConfig;
    }

    @Override
    public Integer updateConfig(DbConfig dbConfig) {
        return dbConfigMapper.updateConfig(dbConfig);
    }

    @Override
    public void test() {
        System.out.println("test dbconfig");
    }
}
